home *** CD-ROM | disk | FTP | other *** search
- program Create_Qmodem_Pcboard_Script;
-
- { This program is written for use with Qmodem 2.0 and PcBoard Bulletin Board }
- { software. The source is included so that if you wish to, you may customize }
- { it to suit your own needs (run on another bulletin board perhaps). }
- { }
- { The program displays a menu of items, from dialing the phone, to hanging it }
- { up, which when selected create a Qmodem script file that will perform each }
- { function with a small amount of error-trapping. For example, it will not }
- { perform an upload of a file which already exists (but the script won't }
- { bomb out either!) }
- { }
- { This program is donated to public domain by: David W. Terry }
- { 3036 Putnam Ct. }
- { West Valley City, Ut 84120 }
- { Feb. 26, 1985 }
- { }
- { If you make changes and distribute your changed code, Please include some }
- { comments to that effect.... }
- { }
- {=============================================================================}
- { Modified by the Lexington Board of Exchange at (606) 277-5993 on 2/28/86 }
- { Added G - Logoff command to main menu }
- { Added delay to Upload and Download functions for reliability }
- { Added sequencing to Enter message function }
- { Added specification of drive and path for Upload filenames }
- {=============================================================================}
-
- type
- str1 = string[1];
- str3 = string[3];
- str12 = string[12];
- str80 = string[80];
-
- var
- Command, { Menu selection variable }
- TransferType: char; { Type of File Transfer desired (X,C,Y) }
- QTransfer: str1; { Qmodem's Transfer type (2,3,6) }
- FileName: str12; { Script File Name, and later up/download names }
- FilePath: str80; { Drive and Path for file to be uploaded }
- FileDesc: str80; { Description of file to be uploaded }
- Count: byte; { a count of the # of up/dnloads (for error trapping) }
- CountStr: str3; { Counter converted to a string }
- ScriptFile: text; { file variable for script }
- InFile: text; { file variable for message entry }
- InText: str80; { text to be uploaded into message }
-
- procedure OpenScript;
- begin
- writeln;
- write('Enter Script File Name: ');
- readln(FileName);
- if FileName<>'' then begin
- if pos('.',FileName)=0 then begin
- gotoxy(25+length(FileName),pred(WhereY));
- writeln('.SCR');
- FileName:=FileName+'.SCR';
- end;
- assign(ScriptFile,FileName);
- rewrite(ScriptFile);
- end;
- end;
-
- procedure GetWaitTime;
- var WaitTime: string[8];
- TimeOk: boolean;
- begin
- write('Enter the time to begin execution (HH:MM:SS): ');
- readln(WaitTime);
- if WaitTime<>'' then begin
- repeat
- TimeOk:=(length(WaitTime)=8) and (WaitTime[3]=':') and (WaitTime[6]=':');
- if not TimeOk then begin
- write(#7,'Please re-enter using military time like (13:00:00): ');
- readln(WaitTime);
- end;
- until TimeOk;
- writeln(ScriptFile,'. **** Wait Until ',WaitTime,' to Begin ****');
- writeln(ScriptFile);
- writeln(ScriptFile,'WAITUNTIL ',WaitTime);
- writeln(ScriptFile);
- end;
- end;
-
- procedure DialPhone;
- var Number: str12;
- begin
- write('Enter Phone Directory Entry Number to dial (prefixes allowed): ');
- readln(Number);
- if Number<>'' then begin
- writeln(ScriptFile,'. **** Dial Entry #',Number,' ****');
- writeln(ScriptFile);
- writeln(ScriptFile,'DIAL "',Number,'"');
- writeln(ScriptFile);
- end;
- end;
-
- procedure Login;
- var Graphics,Quick: str1;
- First,Last,Password: str80;
- begin
- writeln(ScriptFile,'. **** Login to PcBoard ****');
- writeln(ScriptFile);
- write('Do you want Graphics (y or n): ');
- readln(Graphics);
- write('Quick logon (skip logon screen - y or n): ');
- readln(Quick);
- if upcase(Quick)='Y' then Quick:='q' else Quick:='';
- write('First Name: ');
- readln(First);
- write('Last Name: ');
- readln(Last);
- write('Password: ');
- readln(Password);
- writeln(ScriptFile,'WAITFOR "Want"');
- writeln(ScriptFile,'SEND "',Graphics,' ',Quick,'{"');
- writeln(ScriptFile);
- writeln(ScriptFile,'WAITFOR "Name"');
- writeln(ScriptFile,'SEND "',First,' ',Last,' ',Password,'{"');
- writeln(ScriptFile);
- writeln(ScriptFile,'TIMEOUT 10 RETRY');
- writeln(ScriptFile,'RETRY:');
- writeln(ScriptFile,'SEND "{"');
- writeln(ScriptFile,'WAITFOR "Command"');
- writeln(ScriptFile);
- end;
-
- procedure Logoff;
- begin
- Count:=succ(Count);
- str(Count,CountStr);
- writeln(ScriptFile,'. **** Logoff Command ****');
- writeln(ScriptFile);
- writeln(ScriptFile,'TIMEOUT 30 LOGOFF',CountStr);
- writeln(ScriptFile,'SEND "{"');
- writeln(ScriptFile,'WAITFOR "Command"');
- writeln(ScriptFile,'SEND "G{"');
- writeln(ScriptFile,'WAITFOR "calling"');
- writeln(ScriptFile,'LOGOFF',CountStr,':');
- writeln(ScriptFile);
- end;
-
- procedure EnterMessage;
- var ToName,ReText: str80;
- Security: str1;
- begin
- write('Name of Person to send message to (C/R = All, "X" = abort): ');
- readln(ToName);
- if upcase(ToName[1])<>'X' then begin
- write('Message is about: ');
- readln(ReText);
- write('Security on Message (N or C/R = None, R = Receiver): ');
- readln(Security);
- write('Enter name of file to be sent for message text (must exist): ');
- readln(FileName);
- assign(InFile,FileName); {$I-} reset(InFile); {$I+}
- if IOResult<>0 then writeln('ERROR! ',FileName,' does not exist.')
- else begin
- writeln(ScriptFile,'. **** Enter a Message ****');
- writeln(ScriptFile);
- writeln(ScriptFile,'SEND "{"');
- writeln(ScriptFile,'WAITFOR "Command"');
- writeln(ScriptFile);
- writeln(ScriptFile,'SEND "E{"');
- writeln(ScriptFile,'WAITFOR "all?"');
- writeln(ScriptFile);
- writeln(ScriptFile,'SEND "',ToName,'{"');
- writeln(ScriptFile,'WAITFOR "Subject:?"');
- writeln(ScriptFile);
- writeln(ScriptFile,'SEND "',ReText,'{"');
- writeln(ScriptFile,'WAITFOR "None?"');
- writeln(ScriptFile);
- writeln(ScriptFile,'SEND "',Security,'{"');
- writeln(ScriptFile,'WAITFOR "1:"');
- while not eof(InFile) do begin
- readln(InFile,InText);
- if length(InText)<>0 then writeln(ScriptFile,'SEND "',InText,'{"')
- else writeln(ScriptFile,'SEND " {"');
- end;
- writeln(ScriptFile,'SEND "{"');
- writeln(ScriptFile,'WAITFOR "Command?"');
- writeln(ScriptFile);
- writeln(ScriptFile,'SEND "S{"');
- writeln(ScriptFile);
- close(InFile);
- end;
- end;
- end;
-
- procedure WriteScript(UpDown: str1);
- var UpDownStr: str80;
- TypeOk: boolean;
- begin
- write(' ("X"=Xmodem, "C"=Xmodem/CRC, "Y"=Ymodem): ');
- repeat
- readln(TransferType);
- TypeOk:=(pos(upcase(TransferType),'XCY')<>0);
- if not TypeOk then write(#7,'Please Re-enter (X, C, or Y): ');
- until TypeOk;
- case upcase(TransferType) of
- 'X': QTransfer:='2';
- 'Y': QTransfer:='6';
- 'C': QTransfer:='3';
- end;
- case UpDown of
- 'U': UpDownStr:='UPLOAD ';
- 'D': UpDownStr:='DOWNLOAD ';
- end;
- Count:=succ(Count);
- str(Count,CountStr);
- writeln(ScriptFile,'. **** ',UpDownStr,FileName,' ****');
- writeln(ScriptFile);
- writeln(ScriptFile,'TIMEOUT 30 NEXT',CountStr); { Note that the TIMEOUT & }
- writeln(ScriptFile,'SEND "{"'); { NEXTcount are used for }
- writeln(ScriptFile,'WAITFOR "Command"'); { error trapping }
- writeln(ScriptFile);
- writeln(ScriptFile,'TIMEOUT 1 TIME',CountStr); { Generate delay }
- writeln(ScriptFile,'WAITFOR "!@#"'); { Guarantee timeout here }
- writeln(ScriptFile,'TIME',CountStr,':');
- writeln(ScriptFile);
- writeln(ScriptFile,'TIMEOUT 30 NEXT',CountStr); { Reset to previous value }
- writeln(ScriptFile);
- writeln(ScriptFile,'SEND "',UpDown,' ',FileName,' ',TransferType,'{"');
- writeln(ScriptFile,'WAITFOR "Abort."');
- writeln(ScriptFile,UpDownStr,FilePath,FileName,' ',QTransfer);
- writeln(ScriptFile);
- if UpDown='U' then begin
- writeln(ScriptFile,'WAITFOR "? "');
- writeln(ScriptFile,'SEND "',FileDesc,'{"');
- end;
- writeln(ScriptFile,'NEXT',CountStr,':');
- writeln(ScriptFile);
- end;
-
- procedure GetUpload;
- begin
- write('Enter Upload File Name: ');
- readln(FileName);
- if FileName<>'' then begin
- writeln('Enter drive and path for Upload File');
- write(' d:\path\ ([C/R] for default): ');
- readln(FilePath);
- if FilePath <> '' then
- if FilePath[length(FilePath)]<>'\' then FilePath := FilePath + '\';
- writeln('Enter Upload Description: [---------------------------------------]');
- write('(start with / if for sysop only):');
- readln(FileDesc);
- if FileDesc<>'' then begin
- write('Upload Type ');
- WriteScript('U');
- end;
- end;
- end;
-
- procedure GetDownload;
- begin
- write('Enter Download File Name: ');
- readln(FileName);
- FilePath := '';
- if FileName<>'' then begin
- write('Download Type ');
- WriteScript('D');
- end;
- end;
-
- procedure Hangup;
- begin
- writeln(ScriptFile,'HANGUP');
- writeln(ScriptFile);
- writeln(ScriptFile,'. **** End of Session ****');
- end;
-
- begin
- clrscr;
- writeln('Qmodem/PcBoard SCRIPT File Generator -- by David W. Terry, Feb 26, 1985');
- OpenScript;
- if FileName<>'' then begin
- Count:=0;
- gotoxy(1,4);
- writeln('Script Function Menu');
- writeln('--------------------');
- writeln(' W = Wait until HH:MM');
- writeln(' P = Dial Phone');
- writeln(' L = Login');
- writeln(' G = Logoff');
- writeln(' E = Enter a Message (from file based Text)');
- writeln(' U = Upload a file');
- writeln(' D = Download a file');
- writeln(' H = Hangup Phone');
- writeln(' Q = Quit Script Generator');
- window(1,16,80,25);
- gotoxy(1,1);
- repeat
- writeln;
- write('Enter Command: ');
- readln(Command);
- case upcase(Command) of
- 'W': GetWaitTime;
- 'P': DialPhone;
- 'L': Login;
- 'G': Logoff;
- 'E': EnterMessage;
- 'U': GetUpload;
- 'D': GetDownload;
- 'H': Hangup;
- end;
- until upcase(Command)='Q';
- close(ScriptFile);
- end;
- window(1,1,80,25);
- end.